home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / PMODE24.ZIP;1 / EXAMPLES.ZIP / EX_PM3.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-02-05  |  2.9 KB  |  90 lines

  1. ; This program sets up a simple little protected mode handler for the timer
  2. ;  IRQ 0. It just flashes a '0' then a '1' in the upper right corner of the
  3. ;  screen.
  4.  
  5.         .386p
  6. code32  segment para public use32
  7.         assume cs:code32, ds:code32
  8.  
  9. include pmode.inc
  10.  
  11. public  _main
  12.  
  13. ;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
  14. ; DATA
  15. ;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
  16.  
  17. irq_stub_buf    db      21 dup(?)       ; buffer for IRQ callback stub
  18.  
  19. ;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
  20. ; CODE
  21. ;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
  22.  
  23. ;ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕ
  24. _main:
  25.         sti
  26.  
  27.         mov bl,0                        ; get and store old IRQ 0 vector
  28.         call _getirqvect
  29.         push edx
  30.         mov edx,offset pmirq0a          ; set new IRQ 0 protected mode vector
  31.         call _setirqvect
  32.         mov edi,offset irq_stub_buf     ; set real mode IRQ 0 callback
  33.         call _rmpmirqset
  34.         push eax                        ; store old real mode IRQ 0 address
  35.  
  36.         mov byte ptr gs:[0b8000h+158],' '       ; put space on screen
  37.  
  38.         mov v86r_ah,0                   ; wait for key with INT 16h AH=0
  39.         mov al,16h
  40.         int 33h
  41.  
  42.         mov edx,offset pmirq0b          ; set new protected mode IRQ 0
  43.         call _setirqvect
  44.         mov edi,offset irq_stub_buf     ; update real mode callback
  45.         call _rmpmirqset                ;  ignore the EAX passed back this
  46.                                         ;  time since its just the address
  47.                                         ;  of the old callback
  48.  
  49.         mov byte ptr gs:[0b8000h+158],' '       ; put space on screen
  50.  
  51.         mov v86r_ah,0                   ; wait for key with INT 16h AH=0
  52.         mov al,16h
  53.         int 33h
  54.  
  55.         pop eax                         ; restore old real mode IRQ 0 vector
  56.         call _rmpmirqfree
  57.         pop edx                         ; restore old protected mode IRQ 0
  58.         call _setirqvect                ;  vector, though you dont need to do
  59.                                         ;  this before exiting
  60.  
  61.         jmp _exit
  62.  
  63. ;ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
  64. pmirq0a:                ; I think these handlers are pretty self-explanatory
  65.         push eax ds
  66.         mov ds,cs:_selzero
  67.         xor byte ptr ds:[0b8000h+158],' ' xor '0'
  68.         pop ds
  69.         mov al,20h
  70.         out 20h,al
  71.         pop eax
  72.         sti
  73.         iretd
  74.  
  75. ;ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
  76. pmirq0b:
  77.         push eax ds
  78.         mov ds,cs:_selzero
  79.         xor byte ptr ds:[0b8000h+158],' ' xor '1'
  80.         pop ds
  81.         mov al,20h
  82.         out 20h,al
  83.         pop eax
  84.         sti
  85.         iretd
  86.  
  87. code32  ends
  88.         end
  89.  
  90.